package AInventory;

import static org.junit.Assert.*;
import junit.framework.TestCase;

import org.junit.Test;

public class TestAInventory extends TestCase {

	public void testConstructor() {
		Toy t1 = new Toy("baba", 10, 5);
		Toy t2 = new Toy("robot", 15, 7);
		Toy t3 = new Toy("xe", 20, 8);

		AInventory a1 = new MTInventory();
		AInventory a2 = new ConsInventory(t1, a1);
		AInventory a3 = new ConsInventory(t2, a2);
		AInventory a4 = new ConsInventory(t3, a3);
		System.out.println(a4);

	}

	public void testContains() {
		Toy t1 = new Toy("baba", 10, 5);
		Toy t2 = new Toy("robot", 15, 7);
		Toy t3 = new Toy("xe", 20, 8);

		AInventory a1 = new MTInventory();
		AInventory a2 = new ConsInventory(t1, a1);
		AInventory a3 = new ConsInventory(t2, a2);
		AInventory a4 = new ConsInventory(t3, a3);
		assertTrue(a2.contains("baba"));
		assertFalse(a3.contains("hoa tien"));
		assertTrue(a4.contains("xe"));
	}

	public void testIsBellow() {
		Toy t1 = new Toy("baba", 10, 5);
		Toy t2 = new Toy("robot", 15, 7);
		Toy t3 = new Toy("xe", 20, 8);

		AInventory a1 = new MTInventory();
		AInventory a2 = new ConsInventory(t1, a1);
		AInventory a3 = new ConsInventory(t2, a2);
		AInventory a4 = new ConsInventory(t3, a3);
		assertTrue(a2.isBellow(11.0));
		assertTrue(a3.isBellow(20));
		assertTrue(a4.isBellow(30.0));
	}
	public void testHowMany(){
		Toy t1 = new Toy("baba", 10, 5);
		Toy t2 = new Toy("robot", 15, 7);
		Toy t3 = new Toy("xe", 20, 8);

		AInventory a1 = new MTInventory();
		AInventory a2 = new ConsInventory(t1, a1);
		AInventory a3 = new ConsInventory(t2, a2);
		AInventory a4 = new ConsInventory(t3, a3);
		assertEquals(a1.howMany(), 0);
		assertEquals(a2.howMany(), 1);
		assertEquals(a3.howMany(), 2);
		assertEquals(a4.howMany(), 3);
	}
	public void testTBGia(){
		Toy t1 = new Toy("baba", 10, 5);
		Toy t2 = new Toy("robot", 15, 7);
		Toy t3 = new Toy("xe", 20, 8);

		AInventory a1 = new MTInventory();
		AInventory a2 = new ConsInventory(t1, a1);
		AInventory a3 = new ConsInventory(t2, a2);
		AInventory a4 = new ConsInventory(t3, a3);
		assertEquals(a1.tbGia(),0.0);
		assertEquals(a2.tbGia(), 10.0,0.1);
		assertEquals(a3.tbGia(), 12.5,0.1);
		
	}
}
